<template>
	<view>
		<view class="top">
			<view class="">
				<navigator url="/pages/zwj/xiadanchenggong/xiadanchenggong">
					<image class="back" src="/static/images/白色左箭头.png" mode=""></image>
				</navigator>
				<view class="title">
					订单详情
				</view>
			</view>
			<view style="display: flex;margin-left: 30px;margin-top: 15px;">
				<image style=" margin-top: 3px; width: 20px; height: 20px;" src="../../../static/images/商家.png" mode="">
				</image>
				<view style="color: white; margin-left: 10px;">
					<view style="font-size: 15px;">
						{{ merchant.name }}
					</view>
					<view style="font-size: 13px;margin-top: 5px;">
						{{ merchant.address }}
					</view>
				</view>
				<image style="margin-top: 30px; right: 20px; position: fixed; width: 16px;height: 16px;"
					src="../../../static/images/plane.png" mode=""></image>
			</view>
		</view>
		<uni-card style="margin-top: -50px;">
			<view
				style="font-weight: bold; margin-top: 10px; padding-bottom: 10px; border-bottom: 1px solid gainsboro;">
				订单详情
			</view>
			<view v-for="(item, index) in selectedServices" :key="index"
				style="display: flex; justify-content: space-between; margin-top: 10px;">
				<view style="font-size: 13px; font-weight: bold;">{{ item.serviceName }}</view>
				<view style="font-size: 13px; font-weight: bold;">￥{{ item.serviceCurrentPrice
 }}</view>
			</view>

			<view style="display: flex;margin-top: 10px;">
				<view style="font-size: 13px;font-weight: bold;">
					原价
				</view>
				<view style=" position: fixed; right: 30px; font-size: 13px;font-weight: bold;">
					￥{{ totalPrice }}
				</view>
			</view>
			<view style="display: flex;margin-top: 10px;padding-bottom: 10px; border-bottom: 1px solid gainsboro;">
				<view style="font-size: 13px;font-weight: bold;">
					优惠券
				</view>
				<view style=" color: #FF4407; position: fixed; right: 30px; font-size: 12px;font-weight: bold;">
					{{ coupon.name || '没有使用优惠券' }}
				</view>
			</view>
			<view style="display: flex;margin-top: 20px;margin-bottom: 10px;">
				<view style="font-size: 15px;font-weight: bold;">
					支付金额
				</view>
				<view style=" color: #84DEA0; position: fixed; right: 30px; font-size: 20px ;font-weight: bold;">
					￥{{ orderInfo.orderPrice.toFixed(2) }}
				</view>
			</view>
		</uni-card>
		<uni-card>
			<view
				style="font-weight: bold; margin-top: 10px; padding-bottom: 10px; border-bottom: 1px solid gainsboro;">
				订单信息
			</view>
			<view style="display: flex;margin-top: 10px;">
				<view style="font-size: 13px;font-weight: bold;">
					订单号：
				</view>
				<view style=" position: fixed; right: 30px; font-size: 13px;font-weight: bold;">
					{{ orderInfo.orderNum }}
				</view>
			</view>
			<view style="display: flex;margin-top: 10px;">
				<view style="font-size: 13px;font-weight: bold;">
					下单时间：
				</view>
				<view style=" position: fixed; right: 30px; font-size: 13px;font-weight: bold;">
					{{ orderInfo.orderTime }}
				</view>
			</view>
			<view style="display: flex;margin-top: 10px;">
				<view style="font-size: 13px;font-weight: bold;">
					车牌号：
				</view>
				<view style=" position: fixed; right: 30px; font-size: 13px;font-weight: bold;">
					{{ car.carNum }}
				</view>
			</view>
		</uni-card>
	</view>
</template>

<script>
	import request from '../../../uitls/request';
	export default {
		data() {
			return {
				orderInfo: {},
				merchant: {},
				car: {},
				coupon: {},
				totalPrice: '',
				selectedServices: []
			}
		},
		methods: {
			getMerchant() {
				request({
					url: '/merchant/merchant/' + this.orderInfo.merchantId,
					method: 'GET',
					success: (res) => {
						console.log(res)
						this.merchant = res.data.data
					}
				})
			},
			getCar() {
				request({
					url: '/bigbase/carInfo/' + this.orderInfo.carId,
					method: 'GET',
					success: (res) => {
						console.log(res)
						this.car = res.data.data
					}
				})
			},
			getCoupon() {
				if (this.orderInfo.couponId != null) {
					request({
						url: '/xsc/coupon/' + this.orderInfo.couponId,
						method: 'GET',
						success: (res) => {
							console.log(res)
							this.coupon = res.data.data
						}
					})
				}
			}
		},
		onLoad() {
			this.orderInfo = uni.getStorageSync('orderData')
			this.totalPrice = uni.getStorageSync('totalPrice')
			this.selectedServices = uni.getStorageSync('selectedServices')
			console.log(this.selectedServices)
			console.log(this.orderInfo)
			this.getMerchant()
			this.getCar()
			this.getCoupon()
		}
	}
</script>

<style scoped>
	.top {
		width: 100%;
		padding-bottom: 60px;
		background: url(../../../static/images/组 8.png);
		background-repeat: no-repeat;
		background-size: cover;
	}

	.top .back {
		position: absolute;
		margin-left: 20px;
		margin-top: 30px;
		width: 15px;
		height: 15px;
		z-index: 2;
	}

	.top .title {
		text-align: center;
		font-size: 18px;
		color: #fff;
		line-height: 44px;
		/* 根据实际需要调整 */
		padding-top: 20px;
	}
</style>